from django.db import models

# Create your models here.

class Shopkeeper(models.Model):
    name=models.CharField(max_length=50,verbose_name='姓名')
    age=models.CharField(max_length=50,verbose_name='年龄')
    # 自定义表名
    class Meta:
        db_table='shopkeeper'

class Shop(models.Model):
    name=models.CharField(max_length=50,verbose_name='名称')
    price=models.DecimalField(max_digits=7,decimal_places=2,verbose_name='价格')
    account=models.CharField(max_length=50,verbose_name='描述')
    picture=models.ImageField(verbose_name='图片')
    shopkeeper=models.ForeignKey(Shopkeeper,on_delete=models.CASCADE)
    # 自定义表名
    class Meta:
        db_table="shop"

#   创建班级表
class Class(models.Model):
    name=models.CharField(max_length=50,verbose_name='班级名称')
    class Meta:
        db_table='class'

#   创建课程表
class Couser(models.Model):
    name = models.CharField(max_length=50)
    # 加了个外键 还加了个方便反向拿数据的函数related_name跟嵌套序列化器匹配
    cla=models.ForeignKey(Class,on_delete=models.CASCADE,related_name='couser')
    class Meta:
        db_table='couser'

#   创建学生表
class Student(models.Model):
    name = models.CharField(max_length=50, verbose_name='姓名')
    username=models.CharField(max_length=100)
    password=models.CharField(max_length=300)
    cla=models.ForeignKey(Class,on_delete=models.CASCADE)

    class Meta:
        db_table = 'student'